package com.controller;

import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Author: 张波
 * @Time: 2025/8/24 17:29
 */
@Component
public class DateConverter implements Converter<String, Date> {
	@Override
	public Date convert(String s) {
		//将日期字符串转换成日期对象 返回
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		Date date = null;
		try {
			date = format.parse(s);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return date;
	}
}